﻿    <script type="text/javascript">
        $(document).ready(function () {
            var p = new singlepage();
            p.c = "Way.Bus.WMS.ST.Controllers.OutOrder.ST_OutNoticeController";
            p.applyTo = "t1";
            p.showfooter = false;

            p.onForeigned = function (sender, fdata, rows) {
                if (sender.field == "CLIENTNO") {
                    var from = sender.parent;
                    var box1 = from.findbox("CLIENTPHONECODE");
                    var box2 = from.findbox("CLIENTCONTACTPERSON");
                    var grid = from.findgrid("Way.Bus.WMS.Model.StockOutNoticeMaterials");
                    box1.clear();
                    box2.clear();
                    grid.clear();
                }
            }
            p.onSubmited = function (cmd, data, item) {
                if (cmd == "GetStock") {
                    var stock = document.getElementById("stock");
                    var grid = new datagrid();
                    if (!stock) {
                        $("#temp").append("<div id='stock'><div id='stockgrid'><div></div>");
                        stock = document.getElementById("stock");
                    }
                    var ds = new datasource();
                    ds.rows = 1000;
                    ds.setmodel(item.data);
                    grid.datasource = ds;
                    grid.applyTo = "stockgrid";
                    grid.editobj.edit = false;
                    grid.check = true;
                    grid.dblclickrow = function (rowIndex, rowData) {
                        var ge = data.grid.geteditor("NUM");
                        if (ge) {
                            ge.target.val(rowData["KYNUM"]);
                        }
                        var batch = data.grid.geteditor("BATCHNO");
                        if (batch) {
                            batch.target.val(rowData["BATCHNO"]);
                        }
                    }
                    grid.init();
                    grid.load(item.table);
                    $(stock).dialog({
                        title: data.item.MCODE + " - " + data.item.FMODEL + " - " + data.item.F2 + "     库存详细",
                        width: 700,
                        modal: true,
                        resizable: true,
                        height: 400,
                        collapsible: true,
                        cache: false,
                        onClose: function () {
                            $("#stock").panel('destroy');
                            $("#stock").remove();
                        }
                    });
                    return false;
                }
            }
            p.onGridAddOrEdit = function (grid, cmd, item, ischild) {
                if (ischild) {
                    if (cmd == "add" || cmd == "edit") {
                        if (grid.parent) {
                            var box = grid.parent.findbox("ISSQE");
                            var val = box.val();
                            if (val == 1)
                                return true;
                            else
                                return false;
                        }
                    }
                }
            }
            p.init();

        });

        function import3(data) {
            try {
                $('<div id="d2"><div id="d3"/></div>').appendTo($("#temp"));
                var p1 = new datasource();
                p1.c = "Way.Bus.WMS.ST.Controllers.ST_ExcelDRController";
                p1.applyTo = "d3";
                if (data && data.item) {
                    var issubmit = data.item.ISSUBMITED;
                    if (issubmit) {
                        $.messager.alert('提示', '发货通知单已提交，不能进行导入操作！', 'info');
                        return null;
                    }
                } else {
                    $.messager.alert('提示', '请选择一个发库通知单！', 'info');
                    return null;
                }
                //限制主单导入显示
                data.sender.datasource.modeldata.nimport = true;
                window.ddata = data;
                window.pdata = p1;
                p1.init();
                $('#d2').dialog({
                    title: "导入数据",
                    collapsible: false,
                    resizable: false,
                    width: 700,
                    height: 400,
                    cache: false,
                    href: "Views/manager/Exceldr.htm",
                    onClose: function () {
                        $(this).panel('destroy');
                        $("#temp").empty();
                        window.ddata = null;
                    }
                });
            } catch (e) {

            }
        }

        function emport3(data) {
            $('<div id="d2"><div id="d3"/></div>').appendTo($("#temp"));
            var p2 = new singlepage();
            p2.c = "Way.Bus.Controllers.ExcelDCController";
            p2.applyTo = "d3";
            //p1.outc = form.parent.c;
            //p1.ssss = data;
            window.ddata = data;
            window.pdata = p2;
            p2.init();
            $('#d2').dialog({
                title: "导出数据",
                collapsible: false,
                width: 400,
                height: 320,
                cache: false,
                href: p2.datasource.url,
                onClose: function () {
                    $(this).panel('destroy');
                    $("#temp").empty();
                    window.ddata = null;
                }
            });
        }
      </script>
<div id="t1"></div>